package ctm.javacode;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet("/fooddemohistory.do")
public class fooddemohistory extends HttpServlet {

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		/****** 設定 ******/
		response.setContentType("text/html");
		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();// Write the response back to the browser
		String Id = request.getParameter("Id"); //身分證字號字號
		
		HttpSession session = request.getSession();
		String ac = (String) session.getAttribute("login")+";"+Id;
		
		/***可用食物列表***/
		ArrayList<ArrayList<String>> whole_grain_Suit = new ArrayList<ArrayList<String>>(); // 全穀根莖類
		ArrayList<ArrayList<String>> meat_Suit = new ArrayList<ArrayList<String>>(); // 豆魚肉蛋類
		ArrayList<ArrayList<String>> fat_Suit = new ArrayList<ArrayList<String>>(); // 油脂及堅果種子類
		ArrayList<ArrayList<String>> milk_Suit = new ArrayList<ArrayList<String>>(); // 低脂奶類
		ArrayList<ArrayList<String>> fruit_Suit = new ArrayList<ArrayList<String>>(); // 水果類
		ArrayList<ArrayList<String>> vegetables_Suit = new ArrayList<ArrayList<String>>(); // 蔬菜類
		ArrayList<ArrayList<String>> other_Suit = new ArrayList<ArrayList<String>>(); // 其他類
		/***禁忌食物列表***/
		ArrayList<ArrayList<String>> whole_grain_NotSuit = new ArrayList<ArrayList<String>>(); // 全穀根莖類
		ArrayList<ArrayList<String>> meat_NotSuit = new ArrayList<ArrayList<String>>(); // 豆魚肉蛋類
		ArrayList<ArrayList<String>> fat_NotSuit = new ArrayList<ArrayList<String>>(); // 油脂及堅果種子類
		ArrayList<ArrayList<String>> milk_NotSuit = new ArrayList<ArrayList<String>>(); // 低脂奶類
		ArrayList<ArrayList<String>> fruit_NotSuit = new ArrayList<ArrayList<String>>(); // 水果類
		ArrayList<ArrayList<String>> vegetables_NotSuit = new ArrayList<ArrayList<String>>(); // 蔬菜類
		ArrayList<ArrayList<String>> other_NotSuit = new ArrayList<ArrayList<String>>(); // 其他類
		
		classificationfood _classificationfood = new classificationfood(ac);
		whole_grain_Suit = _classificationfood.getsuitfood("全穀根莖類");
		out.print(_classificationfood.webpublish(whole_grain_Suit)+"$"); //'$'為資料間相隔符號
		
		meat_Suit = _classificationfood.getsuitfood("豆魚肉蛋類");
		out.print(_classificationfood.webpublish(meat_Suit)+"$"); //'$'為資料間相隔符號
		
		fat_Suit = _classificationfood.getsuitfood("油脂及堅果種子類");
		out.print(_classificationfood.webpublish(fat_Suit)+"$"); //'$'為資料間相隔符號
		
		milk_Suit = _classificationfood.getsuitfood("低脂奶類");
		out.print(_classificationfood.webpublish(milk_Suit)+"$"); //'$'為資料間相隔符號
		
		fruit_Suit = _classificationfood.getsuitfood("水果類");
		out.print(_classificationfood.webpublish(fruit_Suit)+"$"); //'$'為資料間相隔符號
		
		vegetables_Suit = _classificationfood.getsuitfood("蔬菜類");
		out.print(_classificationfood.webpublish(vegetables_Suit)+"$"); //'$'為資料間相隔符號
		
		other_Suit = _classificationfood.getsuitfood("其他類");
		out.print(_classificationfood.webpublish(other_Suit)+"$"); //'$'為資料間相隔符號
		
		whole_grain_NotSuit = _classificationfood.getnotsuitfood("全穀根莖類");
		out.print(_classificationfood.webpublish(whole_grain_NotSuit)+"$"); //'$'為資料間相隔符號
		
		meat_NotSuit = _classificationfood.getnotsuitfood("豆魚肉蛋類");
		out.print(_classificationfood.webpublish(meat_NotSuit)+"$"); //'$'為資料間相隔符號
		
		fat_NotSuit = _classificationfood.getnotsuitfood("油脂及堅果種子類");
		out.print(_classificationfood.webpublish(fat_NotSuit)+"$"); //'$'為資料間相隔符號
		
		milk_NotSuit = _classificationfood.getnotsuitfood("低脂奶類");
		out.print(_classificationfood.webpublish(milk_NotSuit)+"$"); //'$'為資料間相隔符號
		
		fruit_NotSuit = _classificationfood.getnotsuitfood("水果類");
		out.print(_classificationfood.webpublish(fruit_NotSuit)+"$"); //'$'為資料間相隔符號
		
		vegetables_NotSuit = _classificationfood.getnotsuitfood("蔬菜類");
		out.print(_classificationfood.webpublish(vegetables_NotSuit)+"$"); //'$'為資料間相隔符號
		
		other_NotSuit = _classificationfood.getnotsuitfood("其他類");
		out.print(_classificationfood.webpublish(other_NotSuit)); //'$'為資料間相隔符號
			
		out.close();
	}
}
